const {deployments,ethers, getNamedAccounts} = require("hardhat");
const {expect} = require("chai");



describe("NftAuction Contract", function () {

    before(async function () { 
       [deployer,user1] =  await ethers.getSigners();
       
       await deployments.fixture(["nftV1", "nftAuctionV1"]);

       const nft_deployment = await deployments.get("proxyNft");
       this.nft = await ethers.getContractAt("MyNFT", nft_deployment.address);
        console.log(await this.nft.getAddress())
       
       this.nftAuction_deployment = await deployments.get("proxyNftAuction");
       this.nftAuction = await ethers.getContractAt("NftAuction", this.nftAuction_deployment.address);

    });
    
    it("test auction",async function(){ 

        const nftaddr = await this.nft.getAddress();
        
        await this.nft.mintNFT(deployer);

        await this.nftAuction.createAuction(100000000,20,nftaddr,0);
        //切换用户到user1 进行竞价
        await this.nftAuction.connect(user1).bid(0,{value:100000000});

       const auction = await this.nftAuction.getAuction(0);
        
       expect(auction.highestBidder).to.equal(user1.address);

       
    })

    

    //部署nft拍卖合约


    //授权nft给拍卖合约

    //创建nft拍卖

    //进行拍卖
    
    //等待拍卖结束

});

